#pragma once
#pragma warning( disable : 4244)
#ifndef _SPRITE_H
#define _SPRITE_H

#include "Texture.h"
#include "Viewport.h"

class Sprite
{
private:
	Texture*			_image;

	int					_index;			// Current sprite index
	int					_width;			// Sprite width
	int					_height;		// Sprite height
	int					_totalFrame;	// Number of sprite
	int					_spritePerRow;	// Number of sprite per row

	float					_timeWait2Frame;
	float					_timePerFrame;

	RECT GetDrawRect();
public:
	Sprite(Texture* image, int totalFrame, int spritePerRow, float timePerFrame);
	~Sprite();

	Texture* GetImage() { return _image; }

	void Next(float time);
	void Next(int min, int max, float time);
	void Next(int index);
	int Width() { return _width; }
	int Height() { return _height; }
	int Index(){ return _index; }

	void Render(LPD3DXSPRITE spriteHandler, float x, float y);
	void Render(LPD3DXSPRITE spriteHandler, float x, float y, bool flipY, Viewport* viewport);
	void Render(LPD3DXSPRITE spriteHandler, float x, float y, float zoomX, float zoomY, float angle, Viewport* viewport);
	void Render(LPD3DXSPRITE spriteHandler, float x, float y, RECT rect, Viewport* viewport);
	void Render(LPD3DXSPRITE spriteHandler, float x, float y, RECT rect);
};
#endif
